//页面跳转测试 第一个页面

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';

class  FirstPage extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
     return MaterialApp(
         theme: ThemeData(primaryColor: Colors.blue),
         home: FirstPageWidget());
  }
}

class FirstPageWidget extends StatelessWidget{

   String url ="http://life-moments-private-dev.shall-buy.top/2022/7/10/29dc6807-12d1-4879-b24c-9f14ca8f3a08?imageView2/2/w/1080/interlace/1/q/50/ignore-error/1&e=1657687328&token=NS28RPZpMqUmuhtIE2xDcWtQnRqyL10mTq6aCESm:GkUtIVPJch3XmkLQJiw6PHnbfLw=";
  @override
  Widget build(BuildContext context) {

   return Scaffold(
      appBar: AppBar(title: const Text("我是第一个页面"),),
     body: Center(
       child: RaisedButton(
         onPressed:(){
           Navigator.push(context, MaterialPageRoute(builder: (context) =>  SecondPageWidget()));
         },
         child:
         ClipRRect(borderRadius:BorderRadius.circular(7.0),child:FadeInImage(placeholder:const AssetImage("assets/images/icon_placeholder.gif"),
               image: NetworkImage(url),
               imageErrorBuilder : (context, error, stackTrace) {
                 return Container(
                   child: Image.asset("assets/images/icon_error.png",fit: BoxFit.fill,),
                   height: 150,
                   color: Colors.grey,
                 );
               }
           ),
           )
       ),
     ),
   );

  }
}


class SecondPageWidget extends StatelessWidget{

  @override
  Widget build(BuildContext context) {
    return Scaffold(appBar: AppBar(title: const Text("我是第二个页面"),),

    body:Center(
      child: RaisedButton(
        onPressed: (){
          Navigator.pop(context);
        },
        child: const Text("点击按钮（第二个页面）"),
      ),
    ),);
  }
}


